<%@page language="java" pageEncoding="UTF-8"
	contentType="text/html; charset=UTF-8"%>
<%@ include file="/view/common/taglib.jsp"%>
<%@ include file="/view/common/variable.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<%@ include file="/view/common/head.jsp"%>
<meta name="keywords" content="学而阅读,小说网,原创小说网" />
<meta name="description"
	content="学而阅读,最热门的免费小说网站,提供武侠仙侠,奇幻玄幻,科幻灵异,都市言情,穿越女频,青春校园,历史军事,网游竞技,职业官场等网络热门的书籍下载跟阅读！" />
<title>学而阅读作家后台</title>
<link rel="stylesheet" href="<%=path%>/css/style.css" />
<script type="text/javascript" src="<%=path%>/js/base.js"></script>
<link rel="stylesheet"
	href="<%=path%>/kindeditor/themes/default/default.css" />
<script charset="utf-8" src="<%=path%>/kindeditor/kindeditor-all.js"></script>
<script charset="utf-8" src="<%=path%>/kindeditor/lang/zh-CN.js"></script>
<script type="text/javascript">
	var chapterContent;
	var editor;
	$(document).ready(function() {
		//初始化KindEditor
		editor = KindEditor.ready(function(K) {
			editor = K.create('textarea[name="content1"]', {
				filterMode : true,
				wellFormatMode : true,
				allowPreviewEmoticons : false,
				allowImageUpload : false,
				//items : [ 'source' ],
				items : [],
				resizeType : 0,
				htmlTags : {
					p : [],
					br : []
				},
				afterChange : function() {
					var str = this.text();
					str = delHtmlTag(str);
					chapterContent = str;
					$('#znum').html(str.length);
					$('#chapterWords').val(str.length);
					newlineTag: "p";
					this.sync();
				}
			});
		});
		$("#chapterSeq").keyup(function() { //keyup事件处理 
			$(this).val($(this).val().replace(/\D|^0/g, ''));
			var s = $(this).val();
			if (s >= 10000) {
				$(this).val(10000);
			}

		}).bind("paste", function() { //CTR+V事件处理 
			$(this).val($(this).val().replace(/\D|^0/g, ''));

		}).css("ime-mode", "disabled"); //CSS设置输入法不可用 
	});
	function delHtmlTag(str) {
		str = str.replace(/<\/?[^>]*>/g, ''); //去除HTML tag
		str = str.replace(/[ | ]*\n/g, '\n'); //去除行尾空白
		str = str.replace(/\s+/g, "");
		return str;
	}
	function submitForm() {
		var chapterName = $.trim($("#chapterName").val());
		var chapterSeq = $.trim($("#chapterSeq").val());
		var chapterWords = $.trim($("#chapterWords").val());
		var chapterWriter = $.trim($("#chapterWriter").val());
		if (chapterName != "" && chapterSeq != "" && chapterContent != "") {
			if (chapterWords<=200||chapterWords>8000) {
				$("#validInfo").text("章节内容应为200-8000字区间!");
				return false;
			}
			if (chapterWriter.length > 1000) {
				$("#validInfo").text("作者心得描述字数应小于1000字!");
				return false;
			}
			$("#validInfo").text("");
			$("#form").submit();
		} else {
			$("#validInfo").text("请将信息填写完整!");
			return false;
		}
	}
</script>
</head>

<body ng-app="myApp" ng-controller='ShowController'>
	<%@ include file="/view/common/header.jsp"%>
	<div class="content clearfix">
		<%@ include file="/view/common/left.jsp"%>
		<!--右边-->
		<div class="right r">
			<div class="path">
				作品管理 > <span>作品列表</span>
			</div>
			<div class="editnav">
				<ul>
					<li><a href="<%=path%>/book/detail?bookId=${bookId}">作品设置</a></li>
					<li class="editnavo"><a
						href="<%=path%>/chapter/draftList?bookId=${bookId}">草稿箱</a></li>
					<li><a href="<%=path%>/chapter/publishList?bookId=${bookId}">已发布章节</a></li>
				</ul>
				<a href="<%=path%>/chapter/add?bookId=${bookId}" class="addedit"><img
					src="<%=path%>/image/xzzj.png" /></a>
			</div>
			<!--新增章节-->
			<div class="draftsdet">
				<div class="dsear">
					<input type="text" placeholder="请输入书籍名称" name="bookName"
						id="bookName" /><span><img src="<%=path%>/image/sear.png" /></span>
				</div>
				<form action="<%=path%>/chapter/save" name="form" id="form"
					method="post">
					<input type="hidden" name="bookId" id="bookId" value="${bookId }" />
					<input type="hidden" name="chapterWords" id="chapterWords" value="" />
					<ul class="dform">
						<li><b>书籍名称：</b> <span>${book.bookName}</span></li>
						<li><b>章节付费：</b> <c:if test="${book.bookEnableVIP==1}">
								<label><input type="radio" value="1" name="chapterFree" /><span>免费</span></label>
								<label><input type="radio" value="2" name="chapterFree"
									checked="checked" /><span>付费</span></label>
							</c:if> <c:if test="${book.bookEnableVIP!=1}">
								<label><input type="radio" value="1" name="chapterFree"
									checked="checked" /><span>免费</span></label>
								<label><input type="radio" value="2" name="chapterFree"
									disabled="disabled" /><span>付费</span></label>
								<b>（付费功能审核后开放！）</b>
							</c:if></li>
						<li><b>章节排序：</b> <input type="text" id="chapterSeq"
							name="chapterSeq" value="${chapterSeq }" /><font
							style="color: silver;">（系统自动排序，请勿随意改动！）</font></li>
						<li><b>定时发布：</b> <label><input type="radio"
								name="radio2" checked="checked" /><span>不需要</span></label> <label><input
								type="radio" name="radio2" disabled="disabled" /><span>需要</span></label>
							<b>选择发布时间：</b> <input type="text" id="demo" readonly="readonly" /><font
							style="color: silver;">（下个版本更新将提供该功能！）</font></li>
						<li class="dcontent"><input type="text" id="chapterName"
							name="chapterName" placeholder="此处输入章节号与章节名。示例：“第十章 自由国度”"
							class="dzinp" /> <textarea id="content1" name="content1"
								style="width: 898px; height: 380px; visibility: hidden;"></textarea>
							<span class="znum a_help"><a href="${path}/chapter/help" target="_blank">点击查看使用帮助？</a>&nbsp;&nbsp;（请注意排版，头文字不用缩进，段落要回车换行！）&nbsp;&nbsp;共计：<i
								id="znum">0</i> 字 </span></li>
						<li class="dtextarea"><textarea id="chapterWriter"
								name="chapterWriter" placeholder="作者的话，此段不计入字数"></textarea></li>
						<li><span id="validInfo" style="color: red;"></span></li>
					</ul>
				</form>
				<div class="psave">
					<a id="keep" onclick="submitForm();return false;">保 存</a>
				</div>
			</div>
			<!--新增章节-->
		</div>
		<!--右边-->
	</div>
</body>
</html>